package com.bm.greeting.job;

import com.bm.greeting.config.BaseInfoConfig;
import com.bm.greeting.config.JiNianRiUtils;
import com.bm.greeting.config.Pusher;
import com.bm.greeting.config.ToolsUtils;
import com.bm.greeting.entity.Weather;
import com.bm.greeting.service.impl.SendMail;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;
import java.util.Map;

@Configuration
@EnableScheduling
public class ScheduleTask {

    @Resource
    SendMail sendMail;

//    @Asyncs
//    @Scheduled(cron = "0 0 8 * * ?")
//    public void send() {
//        try {
//            SendWxMessageUtil.sendTextMsgData("@all", SendWxMessageUtil.test(), sendTextMsg());
////            sendMail.sendMessage("小可爱的日常信息", data, "2578394552@qq.com");
//            Pusher.returnBm(BaseInfoConfig.EVERY_DAY_EMAIL_PUSH, BaseInfoConfig.SUCCESS);
//        } catch (Exception e) {
//            Pusher.returnBm(BaseInfoConfig.EVERY_DAY_EMAIL_PUSH, BaseInfoConfig.FAIL);
//        }
//    }


    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void send() {
        try {
            Weather weather = ToolsUtils.getWeather();
            Map<String, String> yiTyjmap = ToolsUtils.getEnsentence();
            Map<String, String> qingShiMap = ToolsUtils.getQingShi();
            String data = "<br>";
            data += "<font  color='#00BFFF'> " + weather.getDate() + "" + weather.getWeek() + " </font>";
            data += "<br>";
            data += "<font  color='#00FFFF'> 天气：" + weather.getText_now() + " </font>";
            data += "<br>";
            data += "<font  color='#EE212D'> 当前温度:" + weather.getTemp() + " </font>";
            data += "<br>";
            data += "<font  color='#173177'> 最低温度:" + weather.getLow() + " </font>";
            data += "<br>";
            data += "<font  color='#FF6347'> 最高温度:" + weather.getHigh() + " </font>";
            data += "<br>";
            data += "<font  color='#42B857'> 风级:" + weather.getWind_class() + " </font>";
            data += "<br>";
            data += "<font  color='#B95EA3'> 风向:" + weather.getWind_dir() + " </font>";

            data += "<br>";
            data += "<font  color='#FF69B4'> " + ToolsUtils.getCaiHongPi() + " </font>";
            data += "<br>";
            data += "<font  color='#FF1493'> 今天是我们恋爱的第" + JiNianRiUtils.getLianAi() + "天 </font>";

            data += "<br>";
            data += "<font  color='#FFA500'> 你老公大人的生日倒计时提醒：" + JiNianRiUtils.getBirthday_Jimmy() + "天 </font>";

            data += "<br>";
            data += "<font  color='#FFA500'> 小可爱的生日倒计时提醒：" + JiNianRiUtils.getBirthday_xy() + "天 </font>";

            data += "<br>";
            data += "<font  color='#C71585'> " + yiTyjmap.get("en") + " </font>";
            data += "<br>";
            data += "<font  color='#C71585'> " + yiTyjmap.get("zh") + " </font>";
            data += "<br>";
            data += "<font  color='#F03752'> " + ToolsUtils.getTheTrickOfLife() + " </font>";

            data += "<br>";
            data += "<font  color='#158BB8'> " + qingShiMap.get("content") + "<<" + qingShiMap.get("source") + ">> " + qingShiMap.get("author") + " </font>";
            data += "<br>";
            data += "<font  color='#DE3F7C'> " + ToolsUtils.getGoodMorning() + " </font>";

            sendMail.sendMessage("小可爱的日常信息（准备改版）", data, "694372334@qq.com");
            Pusher.returnBm(BaseInfoConfig.EVERY_DAY_EMAIL_PUSH, BaseInfoConfig.SUCCESS);
        } catch (Exception e) {
            Pusher.returnBm(BaseInfoConfig.EVERY_DAY_EMAIL_PUSH, BaseInfoConfig.FAIL);
        }
    }

}
